package cn.fntop.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.experimental.UtilityClass;

/**
 * 租户上下文
 */
@UtilityClass
public class TenantContextHolder {
    private static TransmittableThreadLocal<Integer> TENANT_CONTEXT = new TransmittableThreadLocal<>();

    /**
     * 设置租户ID
     * @param tenantId
     */
    public void setTenantId(Integer tenantId) {
        TENANT_CONTEXT.set(tenantId);
    }

    public Integer getTenantId() {
        return TENANT_CONTEXT.get();
    }

    public void clear(){
        TENANT_CONTEXT.remove();
    }
}
